﻿feudal_homogenize_vasals_realm_law_decision = {
	picture = "gfx/interface/illustrations/decisions/decision_realm.dds"

	major = yes
	desc = feudal_homogenize_vasals_realm_law_decision_desc

	is_shown = {
		is_landed = yes
		OR = {
			has_government = clan_government
			has_government = feudal_government
		}
		OR = {
			AND = {
				has_realm_law = crown_authority_0
				any_vassal_or_below = {
					primary_title.tier >= tier_county
					OR = {
						AND = {
							OR = {
								has_government = clan_government
								has_government = feudal_government
							}
							NOT = {
								has_realm_law = crown_authority_0
							}
						}
						AND = {
							has_government = tribal_government
							NOT = {
								has_realm_law = tribal_authority_3
							}
						}
					}
				}
			}
			AND = {
				has_realm_law = crown_authority_1
				any_vassal_or_below = {
					primary_title.tier >= tier_county
					OR = {
						AND = {
							OR = {
								has_government = clan_government
								has_government = feudal_government
							}
							NOT = {
								has_realm_law = crown_authority_1
							}
						}
						AND = {
							has_government = tribal_government
							NOT = {
								has_realm_law = tribal_authority_3
							}
						}
					}
				}
			}
			AND = {
				has_realm_law = crown_authority_2
				any_vassal_or_below = {
					primary_title.tier >= tier_county
					OR = {
						AND = {
							OR = {
								has_government = clan_government
								has_government = feudal_government
							}
							culture = {
								has_innovation = innovation_royal_prerogative
							}
							NOT = {
								has_realm_law = crown_authority_2
							}
						}
						AND = {
							OR = {
								has_government = clan_government
								has_government = feudal_government
							}
							culture = {
								NOT = {
									has_innovation = innovation_royal_prerogative
								}
							}
							NOT = {
								has_realm_law = crown_authority_1
							}
						}
						AND = {
							has_government = tribal_government
							NOT = {
								has_realm_law = tribal_authority_3
							}
						}
					}
				}
			}
			AND = {
				has_realm_law = crown_authority_3
				any_vassal_or_below = {
					primary_title.tier >= tier_county
					OR = {
						AND = {
							OR = {
								has_government = clan_government
								has_government = feudal_government
							}
							culture = {
								has_innovation = innovation_royal_prerogative
							}
							NOT = {
								has_realm_law = crown_authority_3
							}
						}
						AND = {
							OR = {
								has_government = clan_government
								has_government = feudal_government
							}
							culture = {
								NOT = {
									has_innovation = innovation_royal_prerogative
								}
							}
							NOT = {
								has_realm_law = crown_authority_1
							}
						}
						AND = {
							has_government = tribal_government
							NOT = {
								has_realm_law = tribal_authority_3
							}
						}
					}
				}
			}
		}		
	}
	
	is_valid = {		
		is_independent_ruler = yes
		highest_held_title_tier >= tier_kingdom
		is_at_war = no
		is_imprisoned = no
	}	
	effect = {
		custom = fedual_homogenize_realm_law
		hidden_effect = {
			if = {
				limit = {
					has_realm_law = crown_authority_3
				}
				every_vassal_or_below = {
					limit = {
						primary_title.tier >= tier_county
						OR = {
							has_government = clan_government
							has_government = feudal_government
						}
						culture = {
							has_innovation = innovation_royal_prerogative
						}
						NOT = {
							has_realm_law = crown_authority_3
						}
					}
					add_realm_law = crown_authority_3
				}
				every_vassal_or_below = {
					limit = {
						primary_title.tier >= tier_county
						OR = {
							has_government = clan_government
							has_government = feudal_government
						}
						culture = {
							NOT = {
								has_innovation = innovation_royal_prerogative
							}
						}
						NOT = {
							has_realm_law = crown_authority_1
						}
					}
					add_realm_law = crown_authority_1
				}
				every_vassal_or_below = {
					limit = {
						primary_title.tier >= tier_county
						has_government = tribal_government
						NOT = {
							has_realm_law = tribal_authority_3
						}
					}
					add_realm_law = tribal_authority_3
				}
			}
			else_if = {
				limit = {
					has_realm_law = crown_authority_2
				}
				every_vassal_or_below = {
					limit = {
						primary_title.tier >= tier_county
						OR = {
							has_government = clan_government
							has_government = feudal_government
						}
						culture = {
							has_innovation = innovation_royal_prerogative
						}
						NOT = {
							has_realm_law = crown_authority_2
						}
					}
					add_realm_law = crown_authority_2
				}
				every_vassal_or_below = {
					limit = {
						primary_title.tier >= tier_county
						OR = {
							has_government = clan_government
							has_government = feudal_government
						}
						culture = {
							NOT = {
								has_innovation = innovation_royal_prerogative
							}
						}
						NOT = {
							has_realm_law = crown_authority_1
						}
					}
					add_realm_law = crown_authority_1
				}
				every_vassal_or_below = {
					limit = {
						primary_title.tier >= tier_county
						has_government = tribal_government
						NOT = {
							has_realm_law = tribal_authority_3
						}
					}
					add_realm_law = tribal_authority_3
				}
			}
			else_if = {
				limit = {
					has_realm_law = crown_authority_1
				}
				every_vassal_or_below = {
					limit = {
						primary_title.tier >= tier_county
						OR = {
							has_government = clan_government
							has_government = feudal_government
						}
						NOT = {
							has_realm_law = crown_authority_1
						}
					}
					add_realm_law = crown_authority_1
				}
				every_vassal_or_below = {
					limit = {
						primary_title.tier >= tier_county
						has_government = tribal_government
						NOT = {
							has_realm_law = tribal_authority_3
						}
					}
					add_realm_law = tribal_authority_3
				}
			}
			else_if = {
				limit = {
					has_realm_law = crown_authority_0
				}
				every_vassal_or_below = {
					limit = {
						primary_title.tier >= tier_county
						OR = {
							has_government = clan_government
							has_government = feudal_government
						}
						NOT = {
							has_realm_law = crown_authority_0
						}
					}
					add_realm_law = crown_authority_1
				}
				every_vassal_or_below = {
					limit = {
						primary_title.tier >= tier_county
						has_government = tribal_government
						NOT = {
							has_realm_law = tribal_authority_3
						}
					}
					add_realm_law = tribal_authority_3
				}
			}
		}	
	}
	ai_potential = {
		base = 0	
	}

	ai_will_do = {
		base = 0	
	}
	ai_check_interval = 0
}

tribal_homogenize_vasals_realm_law_decision = {
	picture = "gfx/interface/illustrations/decisions/decision_realm.dds"

	major = yes
	desc = tribal_homogenize_vasals_realm_law_decision_desc

	is_shown = {
		is_landed = yes
		has_government = tribal_government
		OR = {
			AND = {
				has_realm_law = tribal_authority_0
				any_vassal_or_below = {
					primary_title.tier >= tier_county
					OR = {
						AND = {
							has_government = tribal_government
							NOT = {
								has_realm_law = tribal_authority_0
							}
						}
						AND = {
							OR = {
								has_government = clan_government
								has_government = feudal_government
							}
							NOT = {
								has_realm_law = crown_authority_0
							}
						}
					}
				}
			}
			AND = {
				has_realm_law = tribal_authority_1
				any_vassal_or_below = {
					primary_title.tier >= tier_county
					OR = {
						AND = {
							has_government = tribal_government
							NOT = {
								has_realm_law = tribal_authority_1
							}
						}
						AND = {
							OR = {
								has_government = clan_government
								has_government = feudal_government
							}
							NOT = {
								has_realm_law = crown_authority_0
							}
						}
					}
				}
			}
			AND = {
				has_realm_law = tribal_authority_2
				any_vassal_or_below = {
					primary_title.tier >= tier_county
					OR = {
						AND = {
							has_government = tribal_government
							NOT = {
								has_realm_law = tribal_authority_2
							}
						}
						AND = {
							OR = {
								has_government = clan_government
								has_government = feudal_government
							}
							NOT = {
								has_realm_law = crown_authority_0
							}
						}
					}
				}
			}
			AND = {
				has_realm_law = tribal_authority_3
				any_vassal_or_below = {
					primary_title.tier >= tier_county
					OR = {
						AND = {
							has_government = tribal_government
							NOT = {
								has_realm_law = tribal_authority_3
							}
						}
						AND = {
							OR = {
								has_government = clan_government
								has_government = feudal_government
							}
							NOT = {
								has_realm_law = crown_authority_1
							}
						}
					}
				}
			}
		}		
	}
	
	is_valid = {		
		is_independent_ruler = yes
		highest_held_title_tier >= tier_kingdom
		is_at_war = no
		is_imprisoned = no
	}	
	effect = {
		custom = tribal_homogenize_realm_law
		hidden_effect = {
			if = {
				limit = {
					has_realm_law = tribal_authority_3
				}
				every_vassal_or_below = {
					limit = {
						primary_title.tier >= tier_county
						has_government = tribal_government
						NOT = {
							has_realm_law = tribal_authority_3
						}
					}
					add_realm_law = tribal_authority_3
				}
				every_vassal_or_below = {
					limit = {
						primary_title.tier >= tier_county
						OR = {
							has_government = clan_government
							has_government = feudal_government
						}
						NOT = {
							has_realm_law = crown_authority_1
						}
					}
					add_realm_law = crown_authority_1
				}
			}
			else_if = {
				limit = {
					has_realm_law = tribal_authority_2
				}
				every_vassal_or_below = {
					limit = {
						primary_title.tier >= tier_county
						has_government = tribal_government
						NOT = {
							has_realm_law = tribal_authority_2
						}
					}
					add_realm_law = tribal_authority_2
				}
				every_vassal_or_below = {
					limit = {
						primary_title.tier >= tier_county
						OR = {
							has_government = clan_government
							has_government = feudal_government
						}
						NOT = {
							has_realm_law = crown_authority_0
						}
					}
					add_realm_law = crown_authority_0
				}
			}
			else_if = {
				limit = {
					has_realm_law = tribal_authority_1
				}
				every_vassal_or_below = {
					limit = {
						primary_title.tier >= tier_county
						has_government = tribal_government
						NOT = {
							has_realm_law = tribal_authority_1
						}
					}
					add_realm_law = tribal_authority_1
				}
				every_vassal_or_below = {
					limit = {
						primary_title.tier >= tier_county
						OR = {
							has_government = clan_government
							has_government = feudal_government
						}
						NOT = {
							has_realm_law = crown_authority_0
						}
					}
					add_realm_law = crown_authority_0
				}
			}
			else_if = {
				limit = {
					has_realm_law = tribal_authority_0
				}
				every_vassal_or_below = {
					limit = {
						primary_title.tier >= tier_county
						has_government = tribal_government
						NOT = {
							has_realm_law = tribal_authority_0
						}
					}
					add_realm_law = tribal_authority_0
				}
				every_vassal_or_below = {
					limit = {
						primary_title.tier >= tier_county
						OR = {
							has_government = clan_government
							has_government = feudal_government
						}
						NOT = {
							has_realm_law = crown_authority_0
						}
					}
					add_realm_law = crown_authority_0
				}
			}
		}	
	}
	ai_potential = {
		base = 0	
	}
	ai_will_do = {
		base = 0	
	}
	ai_check_interval = 0
}